<template>
	<view slot="gBody" class="grace-body" style="padding:0;width: 100%;background: #F5F5F5;height: 100vh;">
		<view class="header" @click="gLogin">
			<view class="avatar">
				<image :src="userInfo.headimgurl" mode=""></image>
			</view>
			<view class="userInfo">
				<view class="userPhone" style="margin-top: 30rpx;">{{userInfo.nickname ? userInfo.nickname : '点击登录'}}</view>
				<!-- <view><text class="tips">成长值0</text></view> -->
			</view>
			<view class="level">
				<view class="name">
					<image src="https://b.yzcdn.cn/member-center/free-icon-1.png" style="width: 30upx;margin-right: 10upx;vertical-align: middle;"
					 mode="widthFix"></image>
					{{vipNewsText}}
				</view>
			</view>
		</view>
		<view class="orderBox outerbox">
			<view class="title">
				<text style="font-weight: 600;font-size:26rpx">我的订单</text>
				<text style="font-size: 24rpx;color: #999;" @click="lookOrder">
					<text>查看全部订单</text>
					<text class="icon-more"></text>
				</text>
			</view>
			<view class="content">
				<view class="item" @click="bindOrder(1)">
					<view class="img">
						<image src="https://b.yzcdn.cn/public_files/2019/04/28/1be3ce61d72286c7ac6e56fbb7d0735c.svg" mode="widthFix"></image>
					</view>
					<view class="text">待付款</view>
				</view>

				<view class="item" @click="bindOrder(2)">
					<view class="img">
						<image src="https://b.yzcdn.cn/public_files/2019/04/28/72cc80f8b65eae45862cafe0d27e78f7.svg" mode="widthFix"></image>
					</view>
					<view class="text">待发货</view>
				</view>
				<view class="item" @click="bindOrder(3)">
					<view class="img">
						<image src="https://b.yzcdn.cn/public_files/2019/04/28/d729a66ef2fe52dd47ae6998921b43fe.svg" mode="widthFix"></image>
					</view>
					<view class="text">待收货</view>
				</view>
				<view class="item" @click="bindOrder(4)">
					<view class="img">
						<image src="https://b.yzcdn.cn/public_files/2019/04/28/a4a60cccd63f9d3ff476cb22f51146d7.svg" mode="widthFix"></image>
					</view>
					<view class="text">评价</view>
				</view>
				<view class="item" @click="bindOrder(5)">
					<view class="img">
						<image src="https://b.yzcdn.cn/public_files/2019/04/28/15ed25836631717b7ff77266a1795328.svg" mode="widthFix"></image>
					</view>
					<view class="text">取消订单</view>
				</view>
			</view>
		</view>
		<!-- 列表操作 -->
		<view class="op-list">
			<view class="op-item" @click="collect">
				<icon class="i-icon-car"></icon>
				<text>我的收藏</text>
				<icon class="more"></icon>
			</view>
		</view>
	</view>
</template>
<script>
	const app = getApp();
	import { vipNews } from '../../api/index.js'
	export default {
		data() {
			return {
				userInfo: {}, //个人信息
				openid:'' ,//用户id
				vipNewsText:''  //会员卡文字
			};
		},
		methods: {
			// 获取会员信息
			async vipNews(){
				let res = await vipNews({ openid:this.openid })
				this.vipNewsText = res
			},
			// 点击登录
			gLogin: function() {
				if(!app.userIdentity()){
					uni.navigateTo({
						url: '/pages/login/login'
					})
					return false;
				}
			},
			// 查看订单
			lookOrder: function() {
				if(!app.userIdentity()){
					uni.navigateTo({
						url: '/pages/login/login'
					})
					return false;
				}
				uni.navigateTo({
					url: `/pageA/order/order`
				})
			},
			
			bindOrder:function(current){
				if(!app.userIdentity()){
					uni.navigateTo({
						url: '/pages/login/login'
					})
					return false;
				}
				uni.navigateTo({
					url: `/pageA/order/order?current=${current}`
				})
			},

			// 我的收藏
			collect: function() {
				if(!app.userIdentity()){
					uni.navigateTo({
						url: '/pages/login/login'
					})
					return false;
				}
				uni.navigateTo({
					url: '/pageA/collection/collection'
				})
			}
		},
		onShow() {
			if (uni.getStorageSync('userInfo') && uni.getStorageSync('userInfo') != undefined) {
				this.userInfo = JSON.parse(uni.getStorageSync('userInfo'));
			}
			this.openid = uni.getStorageSync('openid');
			this.vipNews();
		},
	};
</script>
<style lang="scss" scoped>
	.outerbox {
		width: 90%;
		background: #fff;
		padding: 0 20upx;
		margin: 20rpx auto;

		border-radius: 20upx;
		box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.04);
	}

	.header {
		width: 100%;
		height: 300rpx;
		position: relative;
		display: flex;
		background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
		background-size: 400% 400%;
		animation: gradient 15s ease infinite;

		@keyframes gradient {
			0% {
				background-position: 0% 50%;
			}

			50% {
				background-position: 100% 50%;
			}

			100% {
				background-position: 0% 50%;
			}
		}

		padding-top: 10%;

		.avatar {
			width: 120upx;
			height: 120upx;
			overflow: hidden;
			margin: 0 30rpx;
			background: #f0f0f0;
			background-size: 120upx 120upx;
			border: 1px solid #fff;
			border-radius: 50%;
			box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);

			image {
				width: 100%;
				height: 100%;
			}
		}

		.code {
			position: absolute;
			right: 40upx;
			top: 20upx;
			padding: 10upx 20upx;
			font-size: 24upx;
			border-radius: 40upx;
			background: rgba(0, 0, 0, 0.3);
			color: #fff;

			text {
				margin-right: 8upx;
			}
		}

		.userInfo {
			.userPhone {
				font-size: 40upx;
				font-weight: 700;
				margin-bottom: 20rpx;
				color: #fff;
			}

			.tips {
				border: 1px solid #171717;
				border-radius: 40upx;
				background-image: radial-gradient(circle at 2% 85%, #444039 0, #37332c 82%);
				padding: 4upx 16upx;
				color: #fddda5;
				font-size: 22upx;
				line-height: 32upx;
				letter-spacing: 0;
			}
		}

		.level {
			position: absolute;
			bottom: 0;
			left: 3%;
			width: 94%;
			height: 40px;
			color: #fff;
			border-radius: 8px 8px 0 0;
			box-shadow: 0 -2px 8px 0 rgba(0, 0, 0, 0.2);
			background: rgba(0, 0, 0, 0.8);
			display: flex;
			align-items: center;
			justify-content: space-between;

			.name {
				align-self: flex-start;
				padding-left: 10px;
				overflow: hidden;
				font-size: 12px;
				line-height: 40px;
				white-space: nowrap;
				text-overflow: ellipsis;
				-webkit-line-clamp: 1;
				-webkit-box-orient: vertical;
				color: #ffdea0;
			}

			.toVip {
				padding-right: 10px;
				cursor: pointer;
				color: #fff;
				font-size: 24upx;
			}
		}
	}

	.orderBox {
		.title {
			padding: 30upx 0upx;
			border-bottom: 1px solid #f4f5f6;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.icon-more {
				display: inline-block;
				width: 10rpx;
				height: 15rpx;
				background: url(../../static/images/ckgend.png) no-repeat;
				background-size: cover;
				margin-left: 6rpx;
			}
		}

		.content {
			padding: 40upx 0;
			display: flex;
			align-items: center;
			justify-content: space-around;

			.item {
				text-align: center;

				.img {
					width: 100%;

					image {
						width: 40upx;
					}
				}

				.text {
					font-size: 24upx;
					margin: 10upx 0;
				}
			}
		}
	}

	.ucenter-face {
		width: 100rpx !important;
		height: 100rpx !important;
	}

	.ucenter-face-image {
		width: 100rpx !important;
		height: 100rpx !important;
	}

	.ucenter-line {
		height: 12rpx;
		background-color: #f4f5f6;
		margin: 16rpx 0;
	}

	.op-list {
		padding: 0 20rpx;

		.op-item {
			padding: 24rpx;
			background: #FFFFFF;
			border-radius: 20rpx;
			font-size: 26rpx;
			display: flex;
			align-items: center;

			.i-icon-car {
				width: 30rpx;
				height: 30rpx;
				background: url(../../static/images/icon-shoucang.png) no-repeat;
				background-size: cover;
				margin-right: 20rpx;
			}

			&>text {
				flex: 1;
			}

			.more {
				width: 20rpx;
				height: 30rpx;
				background: url(../../static/images/ckgend.png) no-repeat;
				background-size: cover;
			}
		}
	}
</style>
